<template>
<div>
  <el-dialog title="商品类型" :visible.sync="visible">
    <el-tag class="type-tag" v-for="item in typeList" :key="item.id">
       {{item.name}}
    </el-tag>
  </el-dialog>
</div>
</template>

<script>
export default {
  data () {
    return {
      visible: false,
      typeList: [],
      loading: ''
    }
  },
  methods: {
    init (goodsId) {
      this.loading = this.$loading({ text: '加载中...' })
      this.$http.get('/goods/info/' + goodsId).then(data => {
        this.loading.close()
        if (data.code === 0) {
          this.visible = true
          this.typeList = data.data.typeList
        } else {
          this.$alert(data.msg, {
            type: 'error'
          })
        }
      })
    }
  }
}
</script>

<style scoped>
 .type-tag{
   margin: 5px;
 }
</style>
